﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Sensor.RadarService;

namespace Sensor {
    class Program {

        private static readonly Radar radar = new Radar();
        private static DateTime _lastDate = new DateTime(2000, 1, 1);

        public static void Main(String[] args) {
            Sensor s = new Sensor(60);
            Console.WriteLine("Sensor started...");
            Timer t = new Timer(ShowRep, null, 5000, 10000);
            Console.WriteLine("Timer started...");
            Console.WriteLine("Radar started ...");
            Console.WriteLine("Press Enter to stop server.");
            Console.ReadLine();
        }

        private static void ShowRep(Object o) {
            Console.WriteLine("--------------------------");
            Console.WriteLine("Current registered events:");
            List<Capture> caps = new List<Capture>(radar.GetCaptures(_lastDate));
            caps.ForEach(c  => Console.WriteLine("\tCapture[{0}] - Speed: {1}  |  Plate: {2}  |  Images: {3}"
                , c.id, c.speed, c.plate, radar.GetImages(new int[] {c.id}).Length)
            );
            _lastDate = DateTime.Now;
            Console.WriteLine("--------------------------");
        }
    }
}
